<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/common/commonConfig.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>

<head>
	<base href="<%=basePath%>">
	<title>增加用户注册码信息</title>
	<script src="<%=basePath%>component/layout.js"></script>
    <script src="<%=basePath%>component/toolbar.js"></script>
	<script src='<%=basePath%>dwrsystem/interface/unitService.js'></script>
	<script src='<%=basePath%>dwrsystem/engine.js'></script>
	<script src="<%=basePath%>js/validateJS.js"></script>
</head>

<body>
	<div id="dataObj">
	<div id="displayDiv" class="formlayout" style="width:100%;height:100%;overflow: auto;">
		<form action="<%=basePath%>system-unit/UnitAction!userRegisterNumNew.action" method="post" name="addForm">
			<input type="hidden" name="tuserregisternum.unitId" id="tuserregisternum.unitId" value="${unitId }"/>  
			<table class="inputTable" id="addTable">
				<tr>
					<th>用户注册邀请码 </th>
					<td>
						<input name="tuserregisternum.registerNum" id="tuserregisternum.registerNum" maxlength='25'><span style="color:red;">*</span>
					</td>
				</tr>
				<tr>
					<th>可注册总次数</th>
					<td>
						<input name="tuserregisternum.registerTimesAll" id="tuserregisternum.registerTimesAll" maxlength='15'><span style="color:red;">*</span>
					</td>
				</tr>
				<tr>
					<th>备注</th>
					<td>
						<input name="tuserregisternum.note" id="tuserregisternum.note" maxlength='15'>
					</td>
				</tr>
			</table>
		</form>
	</div></div>
</body>

<script type="text/javascript">
var dhxLayout = createLayoutNormal('1C',false,true);

$(function(){
	configLayout();
});

function configLayout(){
	var a = dhxLayout.cells('a');
	a.hideHeader();
	a.setText('主页面');
	a.fixSize(true, true);
	if(power.getPower() != '' && power.getPowerInsert() )
			createToolbarFromDHXLayoutCell(a,function(toolbar){
			    toolbar.addText("info", 1, "操作:");
			    toolbar.addSeparator("sep1", 2);
			    if(power.getPowerInsert())toolbar.addButton("add", 3, "提交", "save.gif", "save_dis.gif");
			    toolbar.attachEvent("onClick", function(id) {
			    	if(id == 'add'){
			    		validateAdd();
			    	}
			    });
			});
	a.attachObject('dataObj');
}

function validateAdd(){
	var rnum = document.getElementById('tuserregisternum.registerNum').value;
	if(trim(rnum)==''){parent.parent.parent.notifyWarn('请输入用户注册码');return;}
	if (!validatePattern.validateEnglish(rnum,false)){
		parent.parent.parent.notifyWarn('用户注册码非法，只能输入英文');
		return;
	}
	
	var rtimes = document.getElementById('tuserregisternum.registerTimesAll').value;
	if(trim(rtimes)==''){parent.parent.parent.notifyWarn('请输入可注册总次数');return;}
	if (!validatePattern.validateNumber(rtimes,false)){
		parent.parent.parent.notifyWarn('可注册总次数非法，只能输入数字');
		return;
	}

	layoutProgressOn(dhxLayout);
	unitService.hasTUnitUserRegisterNum({registerNum:rnum}, function(data){
		if(data == 1){
			layoutProgressOff(dhxLayout);
			parent.parent.parent.notifyWarn('已存在相同用户注册码');
			return;
		}else{
			document.forms["addForm"].submit();
		}
  	});
}

</script>
</html>
